<?php
use app\Tools\UrlTool;
use app\Tools\StaticTool;
// 引入Js文件
StaticTool::registerJs('admin/access.js', app\assets\LayuiAsset::className());
?>
<fieldset class="layui-elem-field layui-field-title">
    <legend>权限管理 - <?=isset($info['id']) ? '编辑权限' : '添加权限'?></legend>
</fieldset>
<form class="layui-form" action="">
    <input type="hidden" name="id" value="<?=$info ? $info['id'] : ''?>">
    <div class="layui-form-item">
        <label class="layui-form-label">权限名称</label>
        <div class="layui-input-block">
            <input type="text" name="title" autocomplete="off" placeholder="请输入权限名称" class="layui-input" value="<?=$info ? $info['title'] : ''?>">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">分类选择</label>
        <div class="layui-input-block">
            <select name="parent_id" lay-filter="aihao" id="cat-list">
                <option value="0">顶级菜单</option>
                <?php if ($menu): ?>
                <?php foreach ($menu as $k => $m): ?>
                <option value="<?=$k?>" <?php if($info && $info['parent_id'] == $k): ?> selected <?php endif; ?>><?=$m?></option>
                <?php endforeach; ?>
                <?php endif; ?>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">显示为菜单</label>
        <div class="layui-input-block">
            <input type="radio" name="is_menu" value="1" title="是" <?php if(isset($info['is_menu']) && $info['is_menu']): ?> checked <?php endif; ?> >
            <input type="radio" name="is_menu" value="0" title="否" <?php if(isset($info['is_menu']) && !$info['is_menu']): ?> checked <?php endif; ?> >
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">URL列表</label>
        <div class="layui-input-block">
            <textarea name="urls" placeholder="请输入URL,一行一个URL" class="layui-textarea"><?=$info ? $info['urls'] : ''?></textarea>
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="desc" placeholder="" class="layui-textarea"><?=$info ? $info['desc'] : ''?></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" class="layui-btn layui-btn-sm" id="btn-submit">立即提交</button>
            <a class="layui-btn layui-btn-sm" href="<?= UrlTool::createUrl('/admin/access/index') ?>">返回</a>
        </div>
    </div>
</form>